/**
 * Created by lucy on 2018/10/25.
 */
function creatTr(item,val,dataValue,classx){
    var g = "<tr><td class='serialNum'></td>";
    for (var f=0;f<(item.length-2);f++) {
        if(dataValue!=""&&dataValue!=undefined&&f==(item.length-3)){
            g += "<td class='td"+f+"'><input type='text' value='"+dataValue+"'/></td>";
        }else if(f==0&& val!=""&&val!=undefined){
            g += "<td class='td"+f+"'><input type='text' value='"+val+"'/></td>";
        }else{
            g += "<td class='td"+f+"'><input type='text' /></td>";
        }

    }
    g += "<td class='operationIcon' data-checked=true><i title='搜索'  class='iconfont searchPage'>&#xe683;</i><i title='删除' class='iconfont deleteItem'>&#xe6ee;</i><i title='增加一行' class='iconfont addCuloumn'>&#xe601;</i></td></tr>";

    return g
}
function creatTr1(item,data,valx,secondVal,side7Three,id){
    var g = "<tr><td class='serialNum'></td>";
    for (var f=0;f<(item.length-2);f++) {

        if(f==(item.length-3)){
            g += "<td class='td"+f+"'><input type='text' value='"+data+"'/></td>";
        }else{
            if(f==0&&valx!=""&&valx!=undefined){
                g += "<td class='td"+f+"'><input type='text' value='"+valx+"'/></td>";
            }else if(f==3&&(id=="side5"||id=="side6"||id=="side7"||id=="side9")){
                g += "<td class='td"+f+"'><input type='text' value='"+secondVal+"'/></td>";
            }else if(f==5&&(id=="side3"||id=="side8")){
                g += "<td class='td"+f+"'><input type='text' value='"+secondVal+"'/></td>";
            }else if(f==7&&id=="side7"){
                g += "<td class='td"+f+"'><input type='text' value='"+side7Three+"'/></td>";
            }else{
                g += "<td class='td"+f+"'><input type='text' /></td>";
            }

        }
    }
    g += "<td class='operationIcon' data-checked=true><i title='搜索'  class='iconfont searchPage'>&#xe683;</i><i title='删除' class='iconfont deleteItem'>&#xe6ee;</i></td></tr>";

    return g
}
function creatTr12(item,data,valx,secondVal,side7Three,id){
    var g = "<tr><td class='serialNum'></td>";
    for (var f=0;f<(item.length-2);f++) {
        if(f==(item.length-3)){
            g += "<td class='td"+f+"'><input type='text' value='"+data+"'/></td>";
        }else{
            if(f==0&&valx!=""&&valx!=undefined){
                g += "<td class='td"+f+"'><input type='text' value='"+valx+"'/></td>";
            }else if(f==3&&(id=="side5"||id=="side6"||id=="side7"||id=="side9")){
                g += "<td class='td"+f+"'><input type='text' value='"+secondVal+"'/></td>";
            }else if(f==5&&(id=="side3"||id=="side8")){
                g += "<td class='td"+f+"'><input type='text' value='"+secondVal+"'/></td>";
            }else if(f==7&&id=="side7"){
                g += "<td class='td"+f+"'><input type='text' value='"+side7Three+"'/></td>";
            } else{
                g += "<td class='td"+f+"'><input type='text' /></td>";
            }
        }
    }
    g += "<td class='operationIcon' data-checked=true><i title='搜索'  class='iconfont searchPage'>&#xe683;</i><i title='删除' class='iconfont deleteItem'>&#xe6ee;</i><i title='增加一行' class='iconfont addCuloumn'>&#xe601;</i></td></tr>";

    return g
}
function creatTr2(item,data){
    var g = "<tr><td class='serialNum'></td>";
    for (var f in item) {
            g += "<td key="+f+"><input type='text' value='"+item[f]+"'/></td>";
    }
    g += "<td class='operationIcon' data-checked=true><i title='搜索'  class='iconfont searchPage'>&#xe683;</i><i title='删除' class='iconfont deleteItem'>&#xe6ee;</i></td></tr>";
    return g
}
function creatTr22(item,data){
    var g = "<tr><td class='serialNum'></td>";
    for (var f in item) {
        if(f=="newlinenumber"){
            g += "<td key="+f+">"+item[f]+"</td>";
        }else{
            g += "<td key="+f+"><input type='text' value='"+item[f]+"'/></td>";
        }
    }
    g += "<td class='operationIcon' data-checked=true><i title='搜索'  class='iconfont searchPage'>&#xe683;</i><i title='删除' class='iconfont deleteItem'>&#xe6ee;</i><i title='增加一行' class='iconfont addCuloumn'>&#xe601;</i></td></tr>";
    return g
}
function creatTr3(item,data){
    var g = "<tr><td class='serialNum'></td>";
    for (var f in item) {
        g += "<td key="+f+"><input type='text' value='"+item[f]+"'/></td>"
    }
    g += "<td class='operationIcon' data-checked=true><i title='搜索'  class='iconfont searchPage'>&#xe683;</i><i title='删除' class='iconfont deleteItem'>&#xe6ee;</i><i title='增加一行' class='iconfont addCuloumn'>&#xe601;</i></td></tr>";
    return g
}
function creatSingleTr(item){
    var g = "<tr><td class='serialNum'></td>";
    for (var f=0;f<(item.length-2);f++) {
        g += "<td class='td"+f+"'><input type='text'/></td>"
    }
    g += "<td class='operationIcon' data-checked=true><i title='删除' class='iconfont'>&#xe6ee;</i></td></tr>";
    return g
}
//生成可输入表格
function createFormContent(item,state,value){
    var tr =document.createElement("tr");
    var iconFont1 =document.createElement("i");
    var iconFont2 =document.createElement("i");
    var iconFont3 =document.createElement("i");
    iconFont1.setAttribute("class","iconfont searchPage");
    iconFont2.setAttribute("class","iconfont");
    iconFont1.innerHTML="&#xe683;";
    iconFont2.innerHTML="&#xe6ee;";
    iconFont3.setAttribute("class","iconfont addCuloumn");
    iconFont3.innerHTML="&#xe601;";
    for(var i=0;i< item.length;i++){
        var th=document.createElement("td");
        var input =document.createElement("input");
        var disabled=state?true:false
        //input.setAttribute("disabled",disabled)
        if(i==0){
            th.setAttribute("class","serialNum");
        }
        if(i==(item.length-1)){
            th.setAttribute("class","operationIcon")
            th.append(iconFont1);
            th.append(iconFont2)
        }else{
            th.append(input);
            if(i==(item.length-2)){
                th.setAttribute("class","impacObjNum")
                input.setAttribute("value",value?value:"");
            }
        }

        tr.append(th);
    }
    return tr;
}
//生成表格头部
function createForm(item,state){
    var tr =document.createElement("tr");
    for(var i=0;i< item.length;i++){
       var th=document.createElement("th");
        th.innerHTML=item[i].title;
        tr.appendChild(th);
    }
    return tr;
}

//查询数据展示；
function createSearchForm(item,single,batch){
    var tableBox = $(".rightTable");
    for(var m =0 ;m < item.length;m++ ){
        var tr =document.createElement("tr");
        var oThM=document.createElement("th");
        if(batch){
            var oTh=document.createElement("th");
            var oInput =document.createElement("input");
            oInput.setAttribute("type","checkbox");
            oTh.append(oInput);
            tr.append(oTh);
            tr.append(oTh);
        }else{

        }
        oThM.innerHTML=m+1;
        tr.append(oThM);
        for(var n in item[m]){
            var oThdata =document.createElement("th");
            oThdata.innerHTML=item[m][n]
            tr.append(oThdata);
        }
        if(single){
            var iconFont =document.createElement("i");
            var iconDelete =document.createElement("i");
            iconFont.setAttribute("class","iconFont");
            iconFont.innerHTML="操作";
            iconDelete.setAttribute("class","iconDelete");
            iconDelete.innerHTML="删除";
            tr.append(iconFont);
            tr.append(iconDelete);
        }

        tableBox.append(tr)
    }
    return tableBox;
}


function createPageList(title,listLen){//title为头部名称数组

    var g="<table><thead><tr>";
    for(var i =0;i<title.length;i++){
        if(i=0){
            g+="<th> <input type='checkbox' checked="+false+"/>"+title[i]+"</th>"
        }
        g+="<th>"+title[i]+"</th>";
    }
    g+="</tr></thead>";
    g+="<tbody>";
    for(var m=0;m<listLen;m++){
        g+="<tr>";
        for(var j =0;j<title.length;j++){
            if(j=0){
                g+="<td> <input type='checkbox' checked="+false+"/></td>"
            }
            g+="<td></td>";
        }
        g+="</tr>";
    }
    g+="</tbody></table>";

return g;
}


function createSide1(value){
    var g = "<tr><td class='serialNum'></td>";
    for(var v in value){
        g+="<td><input type='text' value='"+value[v]+"'/></td>"
    }

}


function creatTrMore(item){
    var g = "<tr><td class='serialNum'></td>";
    for (var f=0;f<(item.length);f++) {
        g += "<td class='td"+f+"'><input type='text' value='"+item[f]+"' /></td>";
    }
    g += "<td class='operationIcon' data-checked=true><i title='搜索'  class='iconfont searchPage'>&#xe683;</i><i title='删除' class='iconfont deleteItem'>&#xe6ee;</i><i title='增加一行' class='iconfont addCuloumn'>&#xe601;</i></td></tr>";

    return g
}
function creatTrMoreAddNone(item){
    var g = "<tr><td class='serialNum'></td>";
    for (var f=0;f<(item.length);f++) {
        g += "<td class='td"+f+"'><input type='text' value='"+item[f]+"' /></td>";
    }
    g += "<td class='operationIcon' data-checked=true><i title='搜索'  class='iconfont searchPage'>&#xe683;</i><i title='删除' class='iconfont deleteItem'>&#xe6ee;</i><!--<i title='增加一行' class='iconfont addCuloumn'>&#xe601;</i>--></td></tr>";

    return g
}